package com.example.sopt;

import android.app.Activity;
import android.content.Intent;
import android.os.Handler;


public class LauncherUtil 
{
	private static final int DISPLAY_TIME = 3000;
	private static Handler handler;
	private static Intent intent;
	private static boolean isLayoutDefault = true;
	private static int layoutResource;
	

	public static final void go(final Activity activity, final Class<?> cls)
	{
 
		if(isLayoutDefault == true)
		{
			activity.setContentView(R.layout.activity_intro);
		}

		else
		{
			activity.setContentView(layoutResource);
		}
		
		handler = new Handler();
		handler.postDelayed(new Runnable() 
		{
			
			public void run() 
			{
				intent = new Intent(activity, cls);
				activity.startActivity(intent);
				activity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
				activity.finish();
			}
		}, DISPLAY_TIME);
	}
	
	public static final void go(int _layoutResource, final Activity activity, final Class<?> cls)
	{
		isLayoutDefault = false;
		layoutResource = _layoutResource;
		go(activity, cls);
	}
}